{extend name="shop/b2c/Login/base"}
{block name="main"}
<div class="w990"> 
   
   
    <div id="find-pw" class="find-pw2">
    <div class="find-con">
      <div id="sflex04" class="stepflex">
        <dl class="first done">
          <dt class="s-num">1</dt>
          <dd class="s-text"> 填写账户名 <s></s> <b></b> </dd>
        </dl>
        <dl class="normal doing">
          <dt class="s-num">2</dt>
          <dd class="s-text"> 验证身份 <s></s> <b></b> </dd>
        </dl>
        <dl class="normal">
          <dt class="s-num">3</dt>
          <dd class="s-text"> 设置新密码 <s></s> <b></b> </dd>
        </dl>
        <dl class="last">
          <dt class="s-num">&nbsp;</dt>
          <dd class="s-text"> 完成 <s></s> <b></b> </dd>
        </dl>
      </div>
      <div id="find-box" class="uc-box">
        <form action="SHOP_MAIN/login/findpasswd3" method="post" id="fpForm" name="fpForm">
          <div class="find-pwd-con">
            <input type="hidden" name="act" value="to_reset_password" />
            <div id="error_container"></div>
                        <div class="item">
              <label>请选择验证身份方式：</label>
              <select id="validate_type" name="validate_type">
                                <option id="validate_type_email" value="email" val="qiy*****757@126.com">已验证的邮箱</option>
                              </select>
            </div>
            <div class="item v_mobile_phone v_item" style="display: none">
              <label>手机号：</label>
              <span id="l_mobile_phone"></span> </div>
            <div id="c_mobile_code" class="item v_mobile_phone v_item" style="display: none">
              <label>请输入手机短信验证码：</label>
              <input type="text" id="mobile_code" name="mobile_code" class="text text-te2" value="" />
              <input id="zphone" type="button" value="获取手机验证码" class="code">
            </div>
            <div class="item v_email v_item" style="display: none">
              <label>邮箱地址：</label>
              <span id="l_email"></span> </div>
            <div id="c_email" class="item v_email v_item" style="display: none">
              <label>请输入邮箱验证码：</label>
              <input type="text" id="email_code" name="email_code" class="text text-te2" value="" />
              <input id="zemail" type="button" value="获取邮箱验证码" class="code">
            </div>
            <div class="item">
              <input type="button" name="button" id="btn_submit" class="btn_next" value="提交" />
            </div>
             
          </div>
        </form>
      </div>
    </div>
    <script type="text/javascript">
			function show_validate_type(validate_type_obj){
				var type = $(validate_type_obj).val();
				var value = $("#validate_type_"+type).attr("val");
				$("#l_"+type).html(value);
				$(".v_item").hide();
				$(".v_"+type).show();
			}
			
			function send_email_code(emailCodeObj, sendButton){
				// 发送邮件
				var url = 'validate.php';
				$.post(url, {
					act: 'send_email_code'
				}, function(result) {
					if (result == 'ok') {
						//倒计时
						countdown(sendButton);
					} else {
						alert(result);
					}
				}, 'text');
			}
			
			function send_mobile_code(mobileCodeObj, sendButton) {
				// 发送邮件
				var url = 'validate.php';
				$.post(url, {
					act: 'send_mobile_code'
				}, function(result) {
					if (result == 'ok') {
						//倒计时
						countdown(sendButton);
					} else {
						alert(result);
					}
				}, 'text');
			}
			
			$().ready(function(){
				
				show_validate_type($("#validate_type"));
				
				var validator = $("#fpForm").validate({
				    debug: false,
				    rules: {
				    	mobile_code: {
				            required: true
				        },
				        email_code: {
				            required: true
				        }
				    },
				    messages: {
				    	mobile_code: {
				            required: "请输入手机短信验证码"
				        },
				        email_code: {
				            required: "请输入邮箱验证码"
				        }
				    },
				    errorPlacement: function(error, element) {
				        error.appendTo(element.parent());  
				    }
				});
				
				$("#validate_type").change(function(){
					show_validate_type($(this));
				});
				
				$("#zphone").click(function(){
					send_mobile_code($("#mobile_code"), $(this));
				});
				
				$("#zemail").click(function(){
					send_email_code($("#email_code"), $(this));
				});
				
				$("#btn_submit").click(function(){
					
					if(!validator.form()){
				        return;
				    }
					
					$("#fpForm").submit();
					
				});
				
			});
			</script> 
  </div>
   
   
   
   
   
   
   
   
   
   
   
   
  
</div>
{/block}